package org.my.business.controller.web;


import lombok.RequiredArgsConstructor;
import org.my.business.domain.bo.DeviceBo;
import org.my.business.domain.vo.DeviceVo;
import org.my.business.service.IDeviceService;
import org.my.common.mybatis.core.page.PageQuery;
import org.my.common.mybatis.core.page.TableDataInfo;
import org.my.system.domain.SysUser;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * pc端设备控制层
 */
@RequestMapping("/device/pc")
@RequiredArgsConstructor
@RestController
public class PcDeviceController {


    private final IDeviceService deviceService;

    /**
     * 获取设备列表
     */
    @GetMapping("/list")
    public TableDataInfo<DeviceVo> list(DeviceBo device, PageQuery pageQuery) {
        List<DeviceVo> deviceVos = deviceService.selectPageDeviceList(device, pageQuery);
        return TableDataInfo.build(deviceVos);
    }

    /**
     * 单个设备详情
     */
    @GetMapping("/detail")
    public DeviceVo detail(DeviceBo dev) {
        return deviceService.selectOneDev(dev);
    }

    /**
     * 设备状态数量统计（停止、运行）
     */
    @GetMapping("/staNum")
    public HashMap<String,Object> staNum(DeviceBo device) {
        return deviceService.staNum(device);
    }

    /**
     * 员工、客户搜索下拉框内容
     */
    @GetMapping("/users")
    public List<HashMap<String, Object>> users(SysUser user) {
        return deviceService.userList(user);
    }

}
